﻿namespace Cloudio.Core.WebFormsParser
{
    using System.ComponentModel.Design;
    using System.Web.UI;
    using System.Web.UI.Design;

    public class DesignSerializer
    {
        private static readonly IDesignerHost Host;
        private static readonly DesignSurface Surface;

        static DesignSerializer()
        {
            Surface = new DesignSurface();
            Surface.BeginLoad(typeof(CloudioWebFormsRootComponent));

            Host = (IDesignerHost)Surface.GetService(typeof(IDesignerHost));
        }

        public static string Serialize(Control control)
        {
            return ControlPersister.PersistControl(control, Host);
        }
    }
}